//获取应用实例
const app = getApp();
Page({
	data:{		
		imgpath:app.setting.apiimgpath,
		imgUrls:{},
		recommendInfo:{},
		toast_show:false,
		is_login:0,
		title:'开业送大礼',
		description:'欢迎来到四海唐人街，我们在开业之际，给您送出精美礼品，希望您购物愉快。',
		button:'完成注册立即拥有'
	},
	onLoad:function(){	
		var that = this;
		//获取广告
		app.request('/api/Seller/getAd', {apid:1}, function(res){
			if(res.code == '0'){
				//更新数据
				that.setData({
					imgUrls:res.data
				});
			}
		});
		//获取推荐商户
		app.request('/api/Seller/getRecommendSeller', {}, function(res){
			if(res.code == '0'){
				//更新数据
				that.setData({
					recommendInfo:res.data
				});
			}
		});
		var is_member = wx.getStorageSync('is_member');
		if(is_member != 1){
			app.request('/api/Simple/getMarketSet', {}, function(res){
				if(res.code == '0'){
					if(res.data.is_show){
						that.setData({
							title:res.data.title,
							description:res.data.description,
							button:res.data.button,
							toast_show:true
						})
					}	
				}
			});
		}
	},
	onShareAppMessage(res){
		return{
			title:'四海唐人街',
			path:'/pages/index/index',
			imageUrl:'/images/44.jpg'
		}
	},
	possClick:function(){
		wx.getLocation({
			type:'wgs84',  
			success:function(res){
				wx.openLocation({
					latitude:34.319714,
					longitude:108.971161,
					name:"四海唐人街",
					address:"西安市未央区太华北路与凤城三路十字西南角"
				})
			}
		})
	},
	coupon:function(){
		var is_member = wx.getStorageSync('is_member');
		if(is_member){
			wx.navigateTo({
				url:'/pages/discount/discount'
			});
		}else{
			wx.switchTab({
				url:'/pages/memberCenter/memberCenter'
			})
		}
	},
	selle:function(){
		wx.navigateTo({
			url:'/pages/orderdinner/orderdinner'
		});
	},
	car:function(){
		var is_member = wx.getStorageSync('is_member');
		if(is_member){
			wx.navigateTo({
				url:'/pages/bindplate/bindplate'
			});
		}else{
			wx.switchTab({
				url:'/pages/memberCenter/memberCenter'
			})
		}
	},
	activity:function(){
		wx.navigateTo({
			url:'/pages/activitylist/activitylist'
		});
	},
	close_toast:function(){
		var that = this;
		that.setData({
			toast_show: false
    	})
	},
	go_login:function() {
		let that = this
		that.setData({
			toast_show: false
    	})
    	wx.redirectTo({
           url:'/pages/login/login'
        })
	}
})